package com.iaiai.cobra.platform.tencent;

import com.iaiai.cobra.common.util.JsonUtil;
import com.iaiai.cobra.common.util.web.HttpsUtil;
import com.iaiai.cobra.platform.tencent.bean.TencentQueryIpv4AddressResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.hc.core5.http.ParseException;

import java.io.IOException;
import java.net.URISyntaxException;

/**
 * Created with AliyunIpAddress.
 * Package: com.iaiai.cobra.platform.ali
 * Author: iaiai
 * Create Time: 2024/7/29 21:47
 * QQ: 176291935
 * Email: 176291935@qq.com
 * Description: IP归属地查询API
 */
@Slf4j
public class TencentIpAddress {

    //查询当前ip地址
    public static TencentQueryIpv4AddressResponse queryIpv4Address() throws IOException, URISyntaxException, ParseException {
        String response = new HttpsUtil.Builder().build().get("https://r.inews.qq.com/api/ip2city");
        log.info("腾讯 - 查询ip地址：{}",response);
        return JsonUtil.getInstance().deserialize(response, TencentQueryIpv4AddressResponse.class);
    }

}
